package tij4.concurrent.source;

import java.util.concurrent.TimeUnit;

class ADaemon implements Runnable{
    @Override
    public void run() {
        try {
            System.out.print("Starting ADaemon");
            TimeUnit.SECONDS.sleep(1);
        }catch (InterruptedException e){
            System.out.print("Exiting via InterruptedExce");
        }finally {
            System.out.print("This should always run?");
        }
    }
}

/*
    后台进程的finally进程不一定被执行
 */
public class DaemonsDontRunFinally {
    public static void main(String[] args) throws Exception{
        Thread t = new Thread(new ADaemon());
        t.setDaemon(true);
        t.start();
    }
}
